home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / lib / gms.s < prev   
Encoding:
Text File  |  1997-07-08  |  1.6 KB  |  79 lines

  1. ;=======T=======T========================T==========================================;
  2. ;gms.s
  3. ;-----
  4. ;Compile this file and store it in SC:LIB/ if you have SAS/C.  If you have
  5. ;DiceC then store it in dcc:dlib/.
  6. ;
  7. ;Link it to your C programs with the following:
  8. ;
  9. ;  1> sc <source.c> link startup=LIB:gms.o data=far
  10.  
  11.     INCDIR    "INCLUDES:"
  12.     INCLUDE    "games/games_lib.i"
  13.  
  14. CALL    MACRO
  15.     jsr    _LVO\1(a6)
  16.     ENDM
  17.  
  18.     xdef    _GMSBase
  19.     xdef    __XCEXIT
  20.  
  21.     xref    _main
  22.     xref    _PREFSNAME
  23.  
  24. __XCEXIT =    0
  25.  
  26.     SECTION    gms,CODE
  27.  
  28. ;===================================================================================;
  29. ;                            SPECIAL STARTUP CODE
  30. ;===================================================================================;
  31.  
  32. Start:    MOVEM.L    D0-D7/A0-A6,-(SP)
  33.     cmp.l    #"GMSP",d0
  34.     bne.s    .StartFromDOS
  35.     move.l    a1,_GMSBase
  36.     move.l    a1,a6    ;a6 = GMSBase.
  37.     move.l    _PREFSNAME,a0
  38.     CALL    SetUserPrefs
  39.     tst.l    d0
  40.     bne.s    .gexit
  41.     jsr    _main
  42. .gexit    move.l    _GMSBase(pc),a6
  43.     CALL    CloseGMS
  44.     MOVEM.L    (SP)+,D0-D7/A0-A6
  45.     moveq    #$00,d0
  46.     rts
  47.  
  48. .StartFromDOS
  49.     move.l    ($4).w,a6    ;a6 = ExecBase
  50.     lea    GMSName(pc),a1    ;a1 = Library name.
  51.     moveq    #$00,d0    ;d0 = Any version.
  52.     jsr    -552(a6)    ;>> = OpenLibrary()
  53.     move.l    d0,_GMSBase    ;ma = Save base.
  54.     beq.s    .errgms    ;>> = Error, exit.
  55.  
  56.     move.l    d0,a6    ;a6 = GMSBase.
  57.     lea    .exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  58.     move.l    a7,a1    ;a1 = Stack pointer.
  59.     CALL    InitDestruct    ;>> = Initialise the call.
  60.  
  61.     move.l    _PREFSNAME,a0
  62.     CALL    SetUserPrefs
  63.     tst.l    d0
  64.     bne.s    .exit
  65.  
  66.     jsr    _main
  67.  
  68. .exit    move.l    _GMSBase(pc),a6
  69.     CALL    CloseGMS
  70. .errgms    MOVEM.L    (SP)+,D0-D7/A0-A6
  71.     moveq    #$00,d0
  72.     rts
  73.  
  74. _GMSBase dc.l    0
  75.  
  76. GMSName     dc.b    "GMS:libs/dpkernal.library",0
  77.      even
  78.  
  79.